<template>
  <Wmodule title="虫情监测设备">
    <div class="list">
      <div
        v-for="(item, index) in list"
        :key="index"
        :class="['item', index < 2 ? 'item-start' : '']"
      >
        <div class="item-content">{{ item.status || '--' }}</div>
        <div class="item-name">{{ item.statusLabel }}</div>
      </div>
    </div>
  </Wmodule>
</template>
<script setup>
import { ref, watch, toRaw } from 'vue'
import Wmodule from '@/components/wmodule/index.vue'

const props = defineProps({
  data: {
    type: Array,
    default: () => []
  }
})

const list = ref([])

watch(
  () => props.data,
  (newVal) => {
    const _newVal = toRaw(newVal)
    list.value = _newVal
  },
  {
    immediate: true
  }
)
</script>
<style lang="scss" scoped>
.list {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: 1fr 1fr;
  grid-row-gap: 22px;
  .item {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    &.item-start {
      .item-content {
        animation: switch 1s infinite;
      }
    }
    .item-content {
      border-radius: 50%;
      width: 100px;
      height: 100px;
      background: url('@/assets/img/49.png') no-repeat center;
      background-size: 100% 100%;
      // background-size: contain;
      display: flex;
      justify-content: center;
      align-items: center;
      font-family: Microsoft YaHei;
      font-weight: 500;
      font-size: 18px;
      color: #c3ff55;
    }
    .item-name {
      font-family: Microsoft YaHei;
      font-weight: 400;
      font-size: 16px;
      color: #ffffff;
      margin-top: 4px;
    }
  }
}
@keyframes switch {
  25% {
    background: url('@/assets/img/49.png') no-repeat center;
    background-size: 100% 100%;
  }
  75% {
    background: url('@/assets/img/50.png') no-repeat center;
    background-size: 100% 100%;
  }
}
</style>
